package ui;

import java.awt.GridLayout;
import java.awt.event.KeyEvent;

import javax.swing.ButtonGroup;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JRadioButton;

import config.MainConfig;

public class TestRadioButton extends JFrame {
	static String birdString = "Bird";
	static String catString = "Cat";
	static String dogString = "Dog";
	static String rabbitString = "Rabbit";
	static String pigString = "Pig";

	public TestRadioButton() {
		JRadioButton birdButton = new JRadioButton(birdString);
		birdButton.setMnemonic(KeyEvent.VK_B);
		birdButton.setActionCommand(birdString);
		birdButton.setSelected(true);

		JRadioButton catButton = new JRadioButton(catString);
		catButton.setMnemonic(KeyEvent.VK_C);
		catButton.setActionCommand(catString);

		JRadioButton dogButton = new JRadioButton(dogString);
		dogButton.setMnemonic(KeyEvent.VK_D);
		dogButton.setActionCommand(dogString);

		JRadioButton rabbitButton = new JRadioButton(rabbitString);
		rabbitButton.setMnemonic(KeyEvent.VK_R);
		rabbitButton.setActionCommand(rabbitString);

		JRadioButton pigButton = new JRadioButton(pigString);
		pigButton.setMnemonic(KeyEvent.VK_P);
		pigButton.setActionCommand(pigString);

		// Group the radio buttons.
		ButtonGroup group = new ButtonGroup();
		group.add(birdButton);
		group.add(catButton);
		group.add(dogButton);
		group.add(rabbitButton);
		group.add(pigButton);

		JPanel radioPanel = new JPanel(new GridLayout(1, 5));
		radioPanel.add(birdButton);
		radioPanel.add(catButton);
		radioPanel.add(dogButton);
		radioPanel.add(rabbitButton);
		radioPanel.add(pigButton);

		this.add(radioPanel);
		this.setTitle("中天模拟键盘");
		// 设置窗体的大小
		this.setSize(400,300);
		// 设置关闭窗体时，进程结束
		this.setDefaultCloseOperation(3);
		// 设置窗体在屏幕的位置
		this.setLocationRelativeTo(null);
		 this.setVisible(true);
	}
	public static void main(String[] args) {
		new TestRadioButton();
	}
}
